<template>
	<view>
		<navbar :tip="tip" title="更多公告" :isback="true"></navbar>
		<view class="con">
			<view class="con__box" :style="{height:'calc(100vh - 44px - 34rpx - '+height+' - '+bheight+' - '+(tip?'64rpx':'0rpx')+')'}">
				<scroll-view scroll-y="true" style="height: 100%;" v-if="list.length>0" @scrolltolower='scrolltolower'>
					<view class="list">
						<view class="list__item" v-for="(item,index) in list" :key="index">
							{{item.title}}
						</view>
						<u-loadmore @loadmore='scrolltolower' :status="status" />
					</view>
				</scroll-view>
				<u-empty v-else>
				</u-empty>
			</view>
		</view>
	</view>
</template>

<script>
	import home from '@/api/_home.js'
	export default {
		data() {
			return {
				tip: '',
				list:[],
				page:1,
				page_size:20,
				status: 'loadmore',
				total:0
			};
		},
		computed: {
			height() {
				const height = uni.$u.addUnit(uni.$u.sys().statusBarHeight, 'px');
				return uni.$u.deepMerge(height)
			},
			bheight() {
				const height = uni.$u.addUnit(uni.$u.sys().safeAreaInsets.bottom, 'px');
				return uni.$u.deepMerge(height)
			},
		},
		onLoad() {
			this.getlist()
		},
		methods:{
			async getlist(){
				let res = await home.sys_list({page:this.page,page_size:this.page_size})
				if(res.data.code==200){
					this.list=[...this.list,...res.data.data.data]
					this.total = res.data.data.pageInfo.total
					if (this.list.length == this.total) this.status = 'nomore';
				}
			},
			scrolltolower() {
				if (this.list.length == this.total) {
					return
				}
				this.status = 'loading';
				this.page++
				this.getlist()
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: url('https://mp-b54a63ff-3ce2-4df8-8d6e-f855d8976d34.cdn.bspapp.com/img/Rectangle_113.png') 100% no-repeat;
		background-position: top;
		width: 750rpx;
	}

	.con{
		padding: 0 24rpx;
		&__box{
			background: #F1F8FC;
			border-radius: 57rpx 57rpx 0rpx 0rpx;
			overflow: hidden;
			padding-top: 34rpx;
			.list{
				padding: 0 22rpx 34rpx;
				&__item{
					background: #FFFFFF;
					box-shadow: 0rpx 8rpx 8rpx 0rpx rgba(167,173,226,0.25);
					border-radius: 23rpx 23rpx 23rpx 23rpx;
					padding: 14rpx 30rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 23rpx;
					color: #000000;
					line-height: 40rpx;
					margin-bottom: 24rpx;
				}
			}
		}
	}
</style>